package com.keshan.controller;

import com.keshan.utils.DateUtil;
import com.keshan.utils.Msg;
import com.keshan.pojo.WearDevice;
import com.keshan.pojo.WearDeviceJson;
import com.keshan.service.WearDeviceServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author keshan
 * @date 2022/10/21 - 19:59
 */
@CrossOrigin
@Controller
@RequestMapping("/weardevice")
public class WearDeviceController {
    @Autowired
    WearDeviceServices wearDeviceServices;

    @RequestMapping("/insertweardevice")
    @ResponseBody
    public Msg insertBySelectiveToWearDevice(@RequestBody WearDeviceJson wearDeviceJson){
        WearDevice wearDevice =new WearDevice();
        wearDevice.setDeviceType(wearDeviceJson.getDevice_type());
        wearDevice.setFlag(wearDeviceJson.getFlag());
        wearDevice.setImei(wearDeviceJson.getImei());
        wearDevice.setTimeBegin(DateUtil.StringToDate(wearDeviceJson.getTime_begin_str()));
        int result = wearDeviceServices.insertBySelectiveWearDevice(wearDevice);
        return Msg.success().add("result",result);
    }
}
